home *** CD-ROM | disk | FTP | other *** search
/ Hacker's Arsenal - The Cutting Edge of Hacking / Hacker's Arsenal - The Cutting Edge of Hacking.iso / texts / misc / t138.txt < prev    next >
Encoding:
Text File  |  2001-07-11  |  12.2 KB  |  264 lines

  1.  
  2.                            
  3.                    How to make key generators?
  4.                   -===========================-
  5.  
  6. Introduction
  7. ------------
  8. I take no responsibility of the usage of this information.
  9. This tutorial, is for educational knowledge ONLY.
  10.  
  11. Hi there, in this tutorial, I intend to teach you how to make a pretty 
  12. simple keygen, of a program called W3Filer 32 V1.1.3.
  13. W3Filer is a pretty good web downloader...
  14. I guess some of you might know the program.
  15.  
  16. I`ll assume you know:
  17. A.How to use debugger (in this case, SoftIce).
  18. B.How to crack, generally (finding protection routines,patching them,etc...).
  19. C.How to use Disassembler (This knowledge can help).
  20. D.Assembly.
  21. E.How to code in Turbo Pascal (tm).
  22.  
  23. Tools you`ll need:
  24. A.SoftIce 3.00/01 or newer.
  25. B.WD32Asm. (Not a must).
  26. C.The program W3Filer V1.13 (if not provided in this package), can be found in www.windows95.com I believe.
  27. D.Turbo Pascal (ANY version).
  28.  
  29. Well, enough blah blah, let's go cracking...
  30. Run W3Filer 32.
  31. A nag screen pops, and , demands registration (Hmm, this sux ;-)) Now, 
  32. We notice this program has some kind of serial number (Mine is 873977046),
  33. Let's keep the serial in mind, I bet we`ll meet it again while we're on
  34. the debugger.
  35.  
  36. Well, now, let's put your name and a dummy reg code... 
  37. set a BP on GetDlgItemTextA, and, press OK.
  38. We pop inside GetDlgItemTextA, Lets find the registration routine...
  39. I`ll save you the work, the registration routine is this:
  40.  
  41. :00404DB2 8D95A8FAFFFF            lea edx, dword ptr [ebp+FFFFFAA8]
  42. :00404DB8 52                      push edx          ---> Your user name here.
  43. :00404DB9 E80B550000              call 0040A2C9     ---> Registration routine.
  44. :00404DBE 83C408                  add esp, 00000008 ---> Dunno exactly what is it.
  45. :00404DC1 85C0                    test eax, eax     ---> Boolean identifier, 0 if 
  46. :00404DC3 7D17                    jge 00404DDC      ---> registration failed, 1 if
  47.                                                          OK.
  48.  
  49. Well, Let's enter the CALL 40A2C9, and see what's inside it:
  50. (Please read my comments in the code).
  51.  
  52. * Referenced by a CALL at Addresses:
  53. |:00404DB9   , :00407F76   
  54. |
  55. :0040A2C9 55                      push ebp
  56. :0040A2CA 8BEC                    mov ebp, esp
  57. :0040A2CC 81C4B0FEFFFF            add esp, FFFFFEB0
  58. :0040A2D2 53                      push ebx
  59. :0040A2D3 56                      push esi
  60. :0040A2D4 57                      push edi
  61. :0040A2D5 8B5508                  mov edx, dword ptr [ebp+08]
  62. :0040A2D8 8DB500FFFFFF            lea esi, dword ptr [ebp+FFFFFF00]
  63. :0040A2DE 33C0                    xor eax, eax
  64. :0040A2E0 EB16                    jmp 0040A2F8
  65.  
  66. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  67. |:0040A2FB(C)
  68. |
  69. :0040A2E2 0FBE0A                  movsx ecx, byte ptr [edx] ----> Here Starts the interesting part.
  70. :0040A2E5 83F920                  cmp ecx, 00000020         ----> ECX is the the current char in the user name, Hmm, 20h=' '...
  71. :0040A2E8 740D                    je 0040A2F7               ----> Let's see,
  72. :0040A2EA 8A0A                    mov cl, byte ptr [edx]    ----> Generally, all this loop does, is copying
  73.                                                                   the user name from [EDX], to [ESI], WITHOUT the spaces!
  74.                                                                   (Keep this in mind! ).            
  75. :0040A2EC 880C06                  mov byte ptr [esi+eax], cl
  76. :0040A2EF 42                      inc edx
  77. :0040A2F0 40                      inc eax
  78. :0040A2F1 C6040600                mov byte ptr [esi+eax], 00
  79. :0040A2F5 EB01                    jmp 0040A2F8
  80.  
  81. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  82. |:0040A2E8(C)
  83. |
  84. :0040A2F7 42                      inc edx
  85.  
  86. * Referenced by a (U)nconditional or (C)onditional Jump at Addresses:
  87. |:0040A2E0(U), :0040A2F5(U)
  88. |
  89. :0040A2F8 803A00                  cmp byte ptr [edx], 00
  90. :0040A2FB 75E5                    jne 0040A2E2 ----------------> This is the loop , we got what it does, 
  91.                                                                  Let's continue tracing the code...
  92.                                                 
  93. :0040A2FD 56                      push esi     --------> The user name is pushed, in order to 
  94.                                                          Upcase it's chars.                                                        
  95.  
  96. * Reference To: USER32.CharUpperA, Ord:0000h
  97.                                   |
  98. :0040A2FE E80F330000              Call User!CharUpper ---> After this, our name is in upper case.
  99. :0040A303 56                      push esi   -----> Our name in upper case here.
  100.  
  101. * Reference To: cw3220mt._strlen, Ord:0000h
  102.                                   |
  103. :0040A304 E86F300000              Call 0040D378 ---> This is the length of our name.
  104. :0040A309 59                      pop ecx        
  105. :0040A30A 8BC8                    mov ecx, eax  ---> ECX=Length.
  106. :0040A30C 83F904                  cmp ecx, 00000004 ---> Length>=4 (MUST).
  107. :0040A30F 7D05                    jge 0040A316    ---> Let's go to this address...
  108. :0040A311 83C8FF                  or eax, FFFFFFFF
  109. :0040A314 EB67                    jmp 0040A37D
  110.  
  111. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  112. |:0040A30F(C)
  113. |
  114. :0040A316 33D2                    xor edx, edx
  115. :0040A318 33C0                    xor eax, eax
  116. :0040A31A 3BC8                    cmp ecx, eax
  117. :0040A31C 7E17                    jle 0040A335 ---> (Not important, just another useless checking).
  118.  
  119. ===================================================================================
  120. ============ FROM HERE AND ON, THE IMPORTANT CODE, PAY ATTENTION ==================
  121. ===================================================================================
  122.  
  123. One thing before we continue, EDX = 00000000h as we enter to the next instructions.
  124.  
  125. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  126. |:0040A333(C)
  127. |                                
  128. :0040A31E 0FBE1C06                movsx ebx, byte ptr [esi+eax] ---> EBX <--- char in user name, offset EAX.
  129. :0040A322 C1E303                  shl ebx, 03  -----> Hmm, it shl's the char by 03h...(Remember that).
  130. :0040A325 0FBE3C06                movsx edi, byte ptr [esi+eax] ---> Now EDI <--- Char in user name , offset EAX.
  131. :0040A329 0FAFF8                  imul edi, eax   -----> It multiplies the char by the offset in user name! (Remember that).
  132. :0040A32C 03DF                    add ebx, edi    -----> Adds the result to EBX (That was Shelled (Ding Dong =)).
  133. :0040A32E 03D3                    add edx, ebx    -----> EDX=EDX+EBX!!! - This is the CORE of this registration routine!!!
  134. :0040A330 40                      inc eax         -----> Increase EAX by one (next char).
  135. :0040A331 3BC8                    cmp ecx, eax    
  136. :0040A333 7FE9                    jg 0040A31E     ----> If ECX<EAX then, we leave the loop.
  137.  
  138. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  139. |:0040A31C(C)
  140. |
  141. :0040A335 A120674100              mov eax, dword ptr [00416720] ---> HMMMMMM, What's in here?????
  142. :0040A33A C1F803                  sar eax, 03  ---------> WAIT! Please type in SIce '? EAX'
  143.                                                           Does this number in EAX look familiar to us? ;-)
  144.                                                           If you still don`t understand, than, It's 
  145.                                                           our SERIAL NUMBER! (PLEASE, take your time, and check by
  146.                                                           yourself - don`t trust me!). OK, so now we know, 
  147.                                                           That it SHR's EAX by 03 (SAR is almost identical to SHR).
  148. :0040A33D 03D0                    add edx, eax ---------> Hmm, it adds the result from the loop, the serial number shr'd by 03h
  149. :0040A33F 52                      push edx     -------> Let's continue. (At this point, I can tell you , the reg number, is
  150.                                                         in EDX - only that the reg number is in HEX --> That's how you enter it).
  151.  
  152. * Possible StringData Ref from Data Obj ->"%lx"
  153.                                   |
  154. :0040A340 685EF54000              push 0040F55E
  155. :0040A345 8D95B0FEFFFF            lea edx, dword ptr [ebp+FFFFFEB0]
  156. :0040A34B 52                      push edx
  157.  
  158. * Reference To: USER32.wsprintfA, Ord:0000h
  159.                                   |
  160. :0040A34C E8E5320000              Call 0040D636  -------> This one, does HEX2STR (Takes the value from EDX, and turns it to an hex string).
  161. :0040A351 83C40C                  add esp, 0000000C
  162. :0040A354 8D8DB0FEFFFF            lea ecx, dword ptr [ebp+FFFFFEB0] -----> type 'd ecx' - THIS is the reg number! That's enough for us, the rest of 
  163.                                                                            the code, is just for comparing the correct reg code with ours.
  164. :0040A35A 51                      push ecx
  165.  
  166. * Reference To: USER32.CharLowerA, Ord:0000h
  167.                                   |
  168. :0040A35B E8B8320000              Call 0040D618
  169. :0040A360 8D85B0FEFFFF            lea eax, dword ptr [ebp+FFFFFEB0]
  170. :0040A366 50                      push eax
  171. :0040A367 FF750C                  push [ebp+0C]
  172.  
  173. * Reference To: cw3220mt._strcmp, Ord:0000h
  174.                                   |
  175. :0040A36A E875300000              Call 0040D3E4
  176. :0040A36F 83C408                  add esp, 00000008
  177. :0040A372 85C0                    test eax, eax
  178. :0040A374 7405                    je 0040A37B
  179. :0040A376 83C8FF                  or eax, FFFFFFFF
  180. :0040A379 EB02                    jmp 0040A37D
  181.  
  182. * Referenced by a (U)nconditional or (C)onditional Jump at Address:
  183. |:0040A374(C)
  184. |
  185. :0040A37B 33C0                    xor eax, eax
  186.  
  187. * Referenced by a (U)nconditional or (C)onditional Jump at Addresses:
  188. |:0040A314(U), :0040A379(U)
  189. |
  190. :0040A37D 5F                      pop edi
  191. :0040A37E 5E                      pop esi
  192. :0040A37F 5B                      pop ebx
  193. :0040A380 8BE5                    mov esp, ebp
  194. :0040A382 5D                      pop ebp
  195. :0040A383 C3                      ret
  196.  
  197.  
  198.               Making the actual Keygen
  199.               ~~~~~~~~~~~~~~~~~~~~~~~~
  200. Now, after I've explained how does the program calculate the registration
  201. code, you can either write your own keymaker, without looking at my code, or
  202. look at my code (in Turbo Pascal - sorry for all you C lovers ;-) Next time).
  203.  
  204. That's it, here's the source of my keygen:
  205.  
  206.  
  207. ------------------- Cut here ---------------------------------------------
  208.  
  209. Program W3FilerKeygen;
  210. var
  211.    Key,SerialNum,EB,ED,digit:Longint;
  212.    I,x:Byte;
  213.    Name,KeyHex:String;
  214. begin
  215.    Writeln('  W3Filer32 V1.1.3 Keymaker');
  216.    writeln('Cracked by ^pain^ ''97 / Rebels!');
  217.    Write('Your Name:');      { Read the name }
  218.    readln(Name);             
  219.    Write('Serial Number:');
  220.    readln(SerialNum);        {Yes, we need the serial number for the calculation!}
  221.    Key:=0;
  222.    x:=0;
  223.    For I:=1 to length(Name) do
  224.    begin
  225.       Name[I]:=upcase(Name[i]);
  226.       If Name[I]<>' ' then begin
  227.        eb:=ord(Name[I]) shl 3;  {EB = Name[I] Shl 03h}
  228.        Ed:=ord(Name[I]);        {ED = Name[I]}
  229.        ed:=ed*(x);              {ED=ED*Offset}
  230.        inc(x);                  
  231.        eb:=eb+ed;               {Add ED to EB}
  232.        Key:=Key+EB;             {Add EB to KEY}
  233.       end;
  234.    end;
  235.    Key:=Key+(SerialNum shr 3);  { Add SerialNum shr 03h to Key}
  236.  
  237.    { From here, this is just HEX2STRING --> I`m quite sure it's
  238.      Self explaintory, else - go and learn number bases again! ;-)}
  239.    KeyHex:='';
  240.    repeat
  241.       digit:=Key mod 16;
  242.       key:=key div 16;
  243.       If digit<10 then KeyHex:=Chr(Digit+ord('0'))+KeyHex;
  244.       If digit>10 then KeyHex:=Chr(Digit-10+ord('a'))+KeyHex;
  245.    until key=0;
  246.    writeln('Your Key:',KeyHex);
  247.    writeln('                 Enjoy!');
  248. end.
  249.  
  250. --------------------- Cut here -------------------------------------------
  251.  
  252. This tutorial was written by ^pain^ / [mEXELiTE '97], Hope you enjoyed 
  253. reading it, I`m always trying to improve my writing skills =).
  254.  
  255. Hmm, I'd like to greet the following: (No special order)
  256.  
  257. Blast Soft,Teraphy,J0b,Qapla,+ORC,Fravia,Charley,GhostRdr,Odin,kOUGER
  258. Niabi,Acpizer,Klagosong,Mystic Rioter,rANDOM,riDDLER (Come back man!
  259. we NEED ya),yoshi,JosephCo,Leddy,Krazy_N,Vizion,Gunnar_,Volcanic,
  260. Fant0m,Caruso,|PSA|,razzi,ThePharao,|KAIRN| + Everyone in #cracking & in 
  261. #cracking4newbies, And ofcourse - everyone else I forgot. ;)
  262.  
  263. ------------ Signing off - ^pain^ --------------------------------------
  264.